<?php
class MY_Controller extends CI_Controller
{
    public function __construct()
    {
        parent::__construct();
        define("SITEURL",site_url());
        define("BASEURL",base_url());
        define("STATICURL",BASEURL."Public/static/");
        define("UPLOADURL",BASEURL."upload/");
        define("VIEWURL",BASEURL."views/");
        $this->init();
    }
    public function init()
    {
       $version  = $this->config->item('version');
       $this->load->vars(['version'=>$version]);
    }
}


class BaseController extends MY_Controller
{
    public function __construct()
    {
        parent::__construct();
        
        $this->init(); 
    }
    /**
     * 登陆状态检测
     */
    
    public function userInfo($token){
        $this->load->model("user_model","user");
        $userInfo = $this->user->getUserInfoByToken($token);
        if($userInfo['AccountID']){
            $this->user->edit_user($userInfo['AccountID'],array("last_use_time"=>time()));    
        }
        return $userInfo;
    }
}

   

//后台管理控制器
class MY_Luckydog extends CI_Controller
{
	public function __construct()
	{
		parent::__construct();
        $this->load->library('encrypt');
        define("BASEURL",$this->config->item("base_url"));
        define("STATICURL",BASEURL."Public/luckydogstatics/");
        define("UPLOADURL",BASEURL."upload/");
        

	}
	/**
	 * 登陆状态检测
	 */
	public function check_login_status()
	{
		$this->load->model('luckydog/admin_user_model', 'admin_user');
		return $this->admin_user->get_login_status();
	}
    function create_page_links($base_url,$total_cnt,$limit)
    {
        $this->load->library('Pagination');
        $conf_page	= array('base_url'=>$base_url,
            'total_rows'=>$total_cnt,
            'per_page'=>$limit,
            'page_query_string'=>true,
            'first_tag_open'=>'<span class="page_btn">',
            'first_tag_close'=>'</span>',
            'last_tag_open'=>'<span  class="page_btn">',
            'last_tag_close'=>'</span>',
            'prev_tag_open'=>'<span  class="page_btn">',
            'prev_tag_close'=>'</span>',
            'next_tag_open'=>'<span  class="page_btn">',
            'next_tag_close'=>'</span>',
            'num_tag_open'=>'<span  class="page_btn">',
            'num_tag_close'=>'</span>',
            'cur_tag_open'=>'<span  class="page_btn current">',
            'cur_tag_close'=>'</span>',
            'first_link'=>'首页',
            'prev_link'=>'上页',
            'next_link'=>'下页',
            'last_link'=>'末页',
            'num_links'=>5,
            'total_lang'=>'共',
            'pages_lang'=>'页',
            'tiao_lang'=>'条');
        $this->pagination->initialize($conf_page);
        $page_links	= $this->pagination->create_links();
        return $page_links;
    }


}

?>
